import requests,pprint

payload1={
        'action': 'list_course',
        'pagenum': 1,
        'pagesize': 20
}
payload={
        'username':'auto',
        'password':'sdfsdfsdf'
}


sessionid='94xiomzcok9u8u3plckkptoz83833p7o'
headers1={
    # 'username':'liaogan',
    # 'password':123456,
    'cookie':'sessionid='+sessionid
}



payload2={
    'action':'add_course',
    'data':'''{"name":"化学223","desc":"化学课程","display_idx":"80"}
    '''
}


# #josn方式传值
# payload2={
#   "action" : "add_course_json",
#   "data"	 : {
#     "name":"初中化学",
#     "desc":"初中化学课程",
#     "display_idx":"4"
#   }

#登陆用户
# r=requests.post("http://localhost/api/mgr/loginReq",data=payload,headers=headers1)

r=requests.get("http://localhost/api/mgr/sq_mgr/",params=payload1,headers=headers1)
# r1=requests.post("http://localhost/api/mgr/sq_mgr/",data=payload1)
# r2=requests.post("http://localhost/apijson/mgr/sq_mgr/",json=payload2)
list=r.json()
pprint.pprint(list)
# assert list['retcode']==0
# print('test pass')
# isget=False
# for course in list['retlist']:
#     if course['name']=='初中语文':
#         isget=True
#         break
# assert isget



# session='qweracookiessdf123'
# hh='session='+session
# print(hh)
